home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 14824 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: ix.netcom.com!news
  2. From: jlilley@ix.netcom.com (John Lilley)
  3. Newsgroups: comp.lang.c++,de.comp.lang.c++,ualberta.cmput.201
  4. Subject: Re: Another function pointer from a class question?!
  5. Date: 1 Apr 1996 17:23:48 GMT
  6. Organization: Netcom
  7. Message-ID: <4jp3f4$5o5@dfw-ixnews3.ix.netcom.com>
  8. References: <4jls2p$bac@pulp.ucs.ualberta.ca>
  9. NNTP-Posting-Host: den-co6-02.ix.netcom.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-NETCOM-Date: Mon Apr 01 11:23:48 AM CST 1996
  13. X-Newsreader: WinVN 0.99.7
  14.  
  15. In article <4jls2p$bac@pulp.ucs.ualberta.ca>, ryangall@gpu.srv.ualberta.ca 
  16. says...
  17. >
  18. >
  19. >I have an error that I am unsure of.....I want to have a derived class
  20. >that I can pass a function pointer that I will use in a print function.
  21. >If I dont use the print function, and just have the class print off the
  22. >elements in the main function, then it works fine....the class itself 
  23. >works
  24. >well....its just that I get a linker error when I try and run it when 
  25. >using
  26. >the print function.
  27.  
  28. >in list.h....I have the pure virtual class
  29. >
  30. >template<class T>
  31. >class list{
  32. >
  33. >                public:
  34. >
  35. >                virtual T    Add(T)=0;
  36. >                virtual T    Remove(T)=0;
  37. >                virtual T    POPfirst()=0;
  38. >                virtual T    POPlast()=0;
  39. >                virtual int  Inlist(T)=0;
  40. >                virtual int  isempty()=0;
  41. >                virtual void print(void (*)(T))=0;
  42. >
  43. >};
  44. >
  45. >#include "list.h"
  46. >
  47. >template<class T>
  48. >// I used to have this next line, as the delaration but it didnt work,
  49. >//class dl_list : public list<T>{
  50. >// it kept saying that I couldnt use a abstract class directly.
  51.  
  52.  
  53. Try this again, just make sure that when you declare
  54.  
  55.     template <class T> class dl_list : public list<T> {...}
  56.  
  57. That you override *all* of the virtual methods of list<T>.
  58.  
  59. john lilley
  60.  
  61.  
  62.